from selenium import webdriver
from time import sleep
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

# 上传 send_keys
driver = webdriver.Edge()
driver.get('https://www.baidu.com/')
driver.maximize_window()
sleep(2)
# WebDriverWait(driver,20,0.5).until(lambda driver: driver.find_element(By.XPATH,'//*[@id="form"]/span[1]/span[1]').is_displayed())
WebDriverWait(driver,20,0.5).until(EC.presence_of_element_located((By.XPATH,'//*[@id="form"]/span[1]/span[1]')))
# WebDriverWait(driver,20,0.5).until(lambda driver: driver.find_element(By.XPATH,'//*[@id="form"]/span[1]/span[1]').is_displayed())
driver.find_element(By.XPATH,'//*[@id="form"]/span[1]/span[1]').click()
sleep(1)
driver.find_element(By.XPATH,'//*[@id="form"]/div/div[2]/div[2]/input').send_keys(r"C:\Users\18475\Desktop\桌面.png")
sleep(10)

# # 下载 click
# driver.get("https://pypi.org/project/selenium/#files")
# sleep(2)
# driver.find_element(By.XPATH,'//*[@id="files"]/div[1]/div[2]/a[1]').click()
# sleep(10)